package code;

import main.ErrorException;
import define.Config;
import define.ErrorDefine;

public class ReferenceMember 
{
	private ReferenceClass m_class;
	private String m_name;
	private String m_default;
	private String m_comment;
	private Type m_type;
	private StringBuffer m_typeText;
	
	public ReferenceMember(ReferenceClass rc, String name, String type, String defaultValue, String comment) throws ErrorException
	{
		m_class = rc;
		if(name.length() == 0 || type.length() == 0)
		{
			throw new ErrorException(ErrorDefine.E_REFERENCE_NO_NAME_TYPE_ERROR, m_class.getName(), Config.NO_POSITION);
		}
		m_name = name;
		m_default = defaultValue;
		m_comment = comment;
		m_type = new Type(type);
	}
	
	public String getName()
	{
		return m_name;
	}
	
	public String getNameFirstUp()
	{
		if(m_name.length() <= 1)
		{
			return m_name.toUpperCase();
		}
		return m_name.substring(0, 1).toUpperCase() + m_name.substring(1);
	}
	
	public String getDefault()
	{
		return m_default;
	}
	
	public String getComment()
	{
		return m_comment;
	}
	
	public Type getType()
	{
		return m_type;
	}
	
	public void setTypeText(StringBuffer text)
	{
		m_typeText = text;
	}
	
	public StringBuffer getTypeText()
	{
		return m_typeText;
	}
}
